import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: false,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '信息快报平台', icon: 'dashboard' }
    }]
  },
  // 科技-产业
  {
    path: '/techIndustry',
    component: Layout,
    redirect: '/techIndustry/tech/list',
    name: 'TechIndustry',
    meta: { title: '科技产业', icon: 'nested' },
    children: [
      {
        path: 'tech',
        name: 'TechnologyInfo',
        component: () => import('@/views/techIndustry/tech'),
        meta: { title: '科技资讯' },
        children: [
          {
            path: 'list',
            component: () => import('@/views/techIndustry/tech/list'),
            name: 'TechList',
            meta: { title: '科讯列表'},
          },
          {
            path: 'detail/:id',
            name: 'TechDetail',
            component: () => import('@/views/techIndustry/tech/detail'),
            meta: { title: '资讯详情'},
            hidden: true
          },
          {
            path: 'student',
            component: () => import('@/views/techIndustry/student/index'),
            name: 'Student',
            meta: { title: '学生管理'},
          },
          {
            path: 'echart',
            component: () => import('@/views/techIndustry/student/echartView'),
            name: 'echartView',
            meta: { title: 'Echarts页面'},
          },
		      {
            path: 'goods',
            component: () => import('@/views/techIndustry/goods/index'),
            name: 'GoodsList',
            meta: { title: '商品管理'},
          },
        ]
      },
      {
        path: 'industry',
        name: 'Industry',
        component: () => import('@/views/techIndustry/industry'),
        meta: { title: '产业研究'},
        children: [
          {
            path: 'list',
            name: 'IndustryList',
            component: () => import('@/views/techIndustry/industry/list'),
            meta: { title: '产业研究列表' }
          },
          {
            path: 'add/:id',
            name: 'AddResearch',
            component: () => import('@/views/techIndustry/industry/add'),
            meta: { title: '发布最新研究'}
          },
          {
            path: 'detail/:id',
            name: 'ResearchDetail',
            component: () => import('@/views/techIndustry/industry/detail'),
            meta: { title: '产业研究详情'},
            hidden: true
          }
        ]
      }
    ]
  },
  
  // 政策快报
  {
    path: '/policyLetters',
    component: Layout,
    redirect: '/policyLetters/notices',
    name: 'PolicyLetters',
    meta: { title: '政策快报', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'NoticeList',
        component: () => import('@/views/policyLetters/notices/list'),
        meta: { title: '通知公告' }
      },
      {
        path: 'publish/:id',
        name: 'NoticePublish',
        component: () => import('@/views/policyLetters/notices/publish'),
        meta: { title: '发布通知', noCache: true },
        hidden: false
      },
      {
        path: 'policys',
        name: 'PolicyList',
        component: () => import('@/views/policyLetters/policys/list'),
        meta: { title: '政策资料' }
      }
    ]
  },
  // 专业服务
  {
    path: '/service',
    component: Layout,
    redirect: '/service/law',
    name: 'Service',
    meta: { title: '专业服务', icon: 'example' },
    children: [
      {
        path: 'law',
        name: 'LawService',
        component: () => import('@/views/service/law/index'),
        meta: { title: '法律服务'},
        children: [
          {
            path: 'list',
            name: 'LawList',
            component: () => import('@/views/service/law/list'),
            meta: { title: '法律服务列表'}
          },
          {
            path: 'publish/:id',
            name: 'LawListDetail',
            component: () => import('@/views/service/law/publish'),
            meta: { title: '法律服务详情', noCache: true},
            hidden: false  // 用于隐藏菜单
          }
        ]
      },
      {
        path: 'financial',
        name: 'FinancialList',
        component: () => import('@/views/service/financial/index'),
        meta: { title: '财税服务' }
      },
      {
        path: 'personnel',
        name: 'PersonnelList',
        component: () => import('@/views/service/personnel/index'),
        meta: { title: '人才服务', noCache: true },
        hidden: false
      },
      {
        path: 'qualification',
        name: 'QualificationList',
        component: () => import('@/views/service/qualification/index'),
        meta: { title: '资质认定', noCache: true },
        hidden: false
      },
      {
        path: 'intellectual',
        name: 'Intellectuallist',
        component: () => import('@/views/service/intellectual/index'),
        meta: { title: '知识产权服务', noCache: true },
        hidden: false
      },
      {
        path: 'achievement',
        name: 'AchievementList',
        component: () => import('@/views/service/achievement/index'),
        meta: { title: '成果转化服务', noCache: true },
        hidden: false
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // nginx二级域名配置
  base: '/gvsys/',
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
